package com.cube.truthseer.mq.user;


import com.cube.truthseer.common.entity.constants.MqConstants;
import com.cube.truthseer.common.entity.dto.EmailInfoDTO;
import com.cube.truthseer.service.IEmailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class EmailMessageHandler {

    private final IEmailService smsService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "email.message.queue", durable = "true"),
            exchange = @Exchange(MqConstants.Exchange.EMAIL_EXCHANGE),
            key = MqConstants.Key.EMAIL_MESSAGE
    ))
    public void listenSmsMessage(EmailInfoDTO emailInfoDTO){
        log.info("emailInfoDTO:{}",emailInfoDTO);
        smsService.sendMessage(emailInfoDTO);
    }
}
